//
// Created by gogoqiu on 2022/3/24.
//

#ifndef RAPIDSVN_CMAKE_BASEITEM_H
#define RAPIDSVN_CMAKE_BASEITEM_H

#include "wx/wx.h"

//use which type view to fix the key
enum PreferenceViewType{
    PT_INPUT = 0,       //textControl inputDialog
    PT_SWITCH,          //checkbox
    PT_LIST             //
};

/*
 * SqliteQueryEngine::InitTable
 *
 */
enum ColumnName{
    COLUMN_ID, COLUMN_APP_ID, COLUMN_KEY, COLUMN_VIEW_TYPE, COLUMN_DEFAULT_VALUE, COLUMN_VALUE, COLUMN_PROMPT, COLUMN_DESCRIPTION
};

/**
 * 核心数据
 * key
 * title
 * value
 */
class BaseItem{
protected:
    //
    wxString key;
    PreferenceViewType type;
    wxString value;
    wxString defaultValue;
    wxString prompt;
    wxString description;
    //??
    bool valueIsNull;

    BaseItem(){
        valueIsNull = false;
    };
public:
    static BaseItem* NullValueItem( const wxString& key,
                                    const wxString& defaultValue);

    BaseItem( const wxString& key,
              PreferenceViewType type,
              const wxString& defaultValue,
              const wxString& value,
              const wxString& prompt,
              const wxString& description,
              bool _valueIsNull ){
        this->key = key;
        this->type = type;
        this->value = value;
        this->defaultValue = defaultValue;
        this->prompt = prompt;
        this->description = description;
        valueIsNull = _valueIsNull;
    }

    //load from sqlite
    BaseItem( const wxString& key,
              PreferenceViewType type,
              const wxString& defaultValue,
              const wxString& value,
              const wxString& prompt,
              const wxString& description ){
        this->key = key;
        this->type = type;
        this->value = value;
        this->defaultValue = defaultValue;
        this->prompt = prompt;
        this->description = description;
        valueIsNull = false;
    }

    //
    wxString getInsertSql( const wxString& tag );
    wxString getSelectSql( const wxString& tag );

    wxString getKey(){
        return key;
    }

    wxString getValue(){
        return value;
    }

    wxString getDefaultValue(){
        return defaultValue;
    }

    wxString getDescription(){
        return description;
    }

    void setValueIsNull( bool _valueIsNull ){
        this->valueIsNull = _valueIsNull;
    }

    //setKey
    void setValue( const wxString& v ){
        value = v;
    }

    bool getValueIsNull(  ) const{
        return this->valueIsNull;
    }

    PreferenceViewType getType(){
        return type;
    }

    wxString getPrompt(){
        return prompt;
    }

    void setPrompt( wxString prompt ){
        this->prompt = prompt;
    }

    void setDefaultValue( wxString value ){
        this->defaultValue = value;
    }

    void setViewType(PreferenceViewType viewType){
        this->type = viewType;
    }

    void setKey(wxString key){
        this->key = key;
    }

    void setDescription( wxString d ){
        this->description = d;
    }
};



#endif //RAPIDSVN_CMAKE_BASEITEM_H
